
		
			

local lists = {
    {
        '基础力量',
        '每秒力量',
        '杀敌力量',
        '力量成长',
        '力量加成',
    },
    {
        '基础敏捷',
        '每秒敏捷',
        '杀敌敏捷',
        '敏捷成长',
        '敏捷加成',
    },
    {
        '基础智力',
        '每秒智力',
        '杀敌智力',
        '智力成长',
        '智力加成',
    },
	{
        '攻击速度',
        '冷却速度',
        '物理伤害',
        '魔法伤害',
        '普攻输出',
        '技能输出',
    },
}

local data = {}
for _,da in pairs(load_excel('基础设定.xlsx','属性定义')) do
    local name = da.name
    if name then
        data[name] = da
    end
end
local is_race = {}
local max_a = #lists
local max_b = 0
for i,da in ipairs(lists) do
	for a,name in ipairs(da) do
		if data[name] and data[name].is_race then
			is_race[name] = true
		end
	end
    max_b = math.max(max_b,#da)
end

local colors = {0xff00ffff,0xffff9900,0xff00ffff,0xffff9900,0xff00ffff}
local w,h = 220,25
local x0,y0 = 10,65
local w1,h1 = 700,400
local panel = class.panel:builder {
    x = (1920-w1)/2,
    y = 200,
    w = w1,
    h = h1,
    --fdf = 'tooltip_backdrop0',
    normal_image = [[textures\black32.blp]],
    title = {
        type = 'text',
        text = '详细属性',
        font_size = 20,
        align = 5,
        h = 80,
    },
    show_flag = false,
}

panel.items = {}

for i=0,#lists,3 do
    local max_h = 0
    for b=1,3 do
        local da = lists[i+b]
        local color = colors[b]
        if da then
            max_h = math.max(max_h,(#da * h))
            for a,name in ipairs(da) do
                local x,y = x0 + (b-1)*w,y0 + (a-1)*h
                local text1 = panel:add_text(name..'：',x,y,w*0.65,h,12,5)
                local text2 = panel:add_text('10',x+text1.w,y,w - text1.w,h,12,5)
                text1:set_color(color)
                text2.name = name
                text2.key = data[name] and data[name].key or name
                table.insert(panel.items,text2)
            end
        end
    end
    y0 = y0 + max_h + h
end



function panel:update()
    local player = ac.player.self
    local hero = player.hero
    if hero then
        for _,text in ipairs(self.items) do
            local name = text.name
            local key = text.key
            local num = hero:get(key)
            local ex = ''
            if is_race[name] then
                ex = '%'
            end
            if num<10 and num>-10 and num~=0 then
                text:set_text(('%0.1f%s|n'):format(num,ex))
            else
                text:set_text(('%0.f%s|n'):format(num,ex))
            end
        end
    end
end

local button = class.button.create('',550,830,120,50)
button:add_frame('tooltip_backdrop0')
button.text = button:add_text('详细属性',0,0,nil,nil,size or 12,5)
button:set_highlight([[UI\Widgets\BattleNet\bnet-button01-highlight-mouse.blp]])

function button:on_button_mouse_enter()
    panel:show()
end

function button:on_button_mouse_leave()
    panel:hide()
end

ac.game:notify('游戏-注册显示UI',panel)